package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressBookMapper {



    void insert(AddressBook addressBook);


    @Select("select *from address_book where user_id = #{userId}")
    List<AddressBook> selectByUserId(Long userId);

    @Select("select * from address_book where id = #{id}")
    AddressBook selectById(Long id);

    void update(AddressBook addressBook);


    @Delete("delete from address_book where id = #{id}")
    void deleteById(Long id);


    @Update("update address_book set is_default = #{isDefault} where user_id=#{userId}")
    void updateIsDefaultByUserId(AddressBook addressBook);


    @Update("update address_book set is_default = #{isDefault} where id=#{id}")

    void updateIsDefaultById(AddressBook addressBook);


    @Select("select * from address_book where user_id =#{userId} and is_default =#{isDefault}")
    List<AddressBook> selectByUserIdWithIsDefault(AddressBook addressBook);
}
